<script setup>
import { getArticlesAPI } from '@/api/tools'

const search = ref('') //搜索内容
const articlesList = ref()

async function getArticles() {
    const res = await getArticlesAPI({
        title: search.value
    })
    articlesList.value = res.data.value.data
    articlesList.value.forEach(item => {
        item.circleTitle = item.title.substring(0, 4)
    })
}

getArticles()
</script>

<template>
    <div class="container">

        <div class="app-nav">
            <div class="tools-img">
                <div class="tools-title">
                    AI工具箱，你的好帮手！
                </div>
                <div class="tools-search-box">
                    <div class="tools-search-boxs">
                        <input type="search" class="tools-search" placeholder="请在这输入搜索的内容" v-model="search">
                        <div class="tools-search-btn" @click="getArticles">
                            搜索一下
                        </div>
                    </div>
                </div>
                <!-- <div class="index-img-mask"></div> -->
            </div>
            <div class="tools-little-title">
                <div class="nav-tag-title">
                <div>
                    全部工具
                </div>
                <div style="margin-left: 10px;color: #8E8E8E;font-size: 16px;">
                    All tools
                </div>
            </div>
            </div>
            <div class="tools-box">
                <ul>
                    <li class="tools-box-nav" v-for="item in articlesList">
                        <NuxtLink :to="`/tools/${item.atricleId}`">
                            <div class="tools-box-nav-title">
                                <!-- {{ item.circleTitle }} -->
                                <img src="../../static/icon.png" alt="" style="width: 70px;height: 70px">
                            </div>
                            <div class="tools-box-nav-content">
                                <div class="tools-box-nav-content-title">
                                    {{ item.title }}
                                </div>
                                <div class="tools-box-nav-content-text">
                                    {{ item.introduction }}
                                </div>
                            </div>
                        </NuxtLink>

                    </li>

                </ul>
            </div>
        </div>
    </div>

</template>

<style scoped>
.index-img-mask {
    z-index: -999;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, .4);
}

.container {
    width: 100%;
    /* height: 100vh; */
    /* background-color: #f2f3fa; */
}

.tools-img {
    width: 100%;
    height: 400px;
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: url('../../static/indexbg.png') center/cover;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

ul {
    list-style: none;
}

.app-nav {
    margin: 0 auto;
    width: 100%;
    /* max-width: 1170px; */
    height: 100%;
    min-height: 100vh;
}

.tools-title {
    /* margin-top: 20px; */
    padding-bottom: 40px;
    font-size: 32px;
    font-weight: bold;
    text-align: center;

    /* color: #fff; */
}

.tools-box ul {
    width: 100%;
    max-width: 1170px;
    margin: 0 auto;
    margin-top: 20px;
}

.tools-box-nav {
    display: flex;
    flex-direction: row;
    background-color: #fff;
    /* box-shadow: 0 0 10px #0003; */
    /* float: left; */
    padding: 15px;
    margin: 10px;
    width: 230px;
    /* height: 80px; */
    border-radius: 8px;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: inline-block;
    transition: .5s all;
    box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.08), 0px 1px 4px 0px rgba(0, 0, 0, 0.04);
}

.tools-box-nav:hover {
    /* box-shadow: 0 0 10px #655aec; */
    transform: translateY(-5px);
    transition: .5s all;

    .tools-box-nav-content-title {
        color: #655aec;
    }
}

.tools-box-nav-title {
    border-radius: 60px;
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* background-color: #655aec; */
    /* border: 1px solid #655aec; */
    font-weight: bold;
    /* box-shadow: 0 0 10px #333; */
    color: #655aec;
    font-size: 16px;
}

.tools-search-box {
    margin-top: 20px;
    width: 100%;
    max-width: 1170px;
    /* padding: 30px; */
    display: flex;
    justify-content: center;
    align-items: center;
}

.tools-search {
    /* border: none; */
    border: 1px solid rgba(26, 37, 243, 0.5);
    /* border: 1px solid #655aec; */
    width: 100%;
    max-width: 468px;
    height: 40px;
    /* margin: 2px 5px; */
    outline: 0 none;
    /* border-radius: 20px; */
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    font-size: 16px;
    padding: 10px;
}

.tools-search-boxs {
    width: 100%;
    max-width: 1170px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tools-search-btn {
    width: 108px;
    height: 40px;
    border-bottom-right-radius: 10px;
    border-top-right-radius: 10px;
    text-align: center;
    line-height: 40px;
    color: #fff;
    /* font-size: 24px; */
    background-color: #1A25F3;
}

.tools-box-nav-content {
    margin-left: 10px;
}

.tools-box-nav-content-title {
    font-size: 18px;
    font-weight: 600;
    box-sizing: border-box
}

.tools-box-nav-content-text {
    color: #a0a3bd;
    font-size: 14px;
    font-weight: 400;
    width: 150px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a {
    text-decoration: none;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tools-little-title {
    width: 100%;
    max-width: 1170px;
    margin: 0 auto;

}

.nav-tag-title,
.nav-prompt-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-weight: bold;
    font-size: 24px;
    /* color: #655aec; */
}

@media (max-width: 992px) {
    .tools-box ul {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }

    .tools-box-nav {
        width: 350px;
    }

    .tools-box-nav-content {
        width: 200px;
    }

    .tools-box-nav-content-text {
        width: 200px
    }
}
</style>
